package com.github.yoojia.mqtt.boot;

import com.parkingwang.lang.data.Config;

/**
 * @author Yoojia Chen (yoojiachen@gmail.com)
 * @since 1.0.0
 */
final class PluginConf {

    public final String className;
    public final boolean disabled;
    public final Config arguments;

    private PluginConf(String className, boolean disabled, Config arguments) {
        if (className.contains(".")) {
            this.className = className;
        } else {
            this.className = "com.github.yoojia.mqtt.boot.plugins." + className;
        }
        this.disabled = disabled;
        this.arguments = arguments;
    }

    static PluginConf of(Config config) {
        return new PluginConf(
                config.getString("class"),
                config.getBoolean("disabled"),
                config.getConfig("arguments")
        );
    }
}
